package labReport.experiment3;

abstract class Shape {
    private String name;

    //无参构造方法
    public Shape() {
    }

    //有参构造方法
    public Shape(String name) {
        this.name = name;
    }

    //形状面积
    abstract double shapeArea(double r);

    //形状周长
    abstract double shapePerimeter(double r);

    //setter和getter方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

//Circle类 继承 Shape类
class Circle extends Shape {
    double pi = Math.PI;

    @Override
    double shapeArea(double r) {
        return pi * r * r;
    }

    @Override
    double shapePerimeter(double r) {
        return pi * 2 * r;
    }
}

public class ShapeAndCircleTest {
    public static void main(String[] args) {
        Circle circle = new Circle();
        double area = circle.shapeArea(5.0f);
        double length = circle.shapePerimeter(5.0f);
        System.out.printf("圆形面积 = %.5f\n圆形周长 = %.6f", area, length);
    }
}
